﻿package org.aquiferserver.client.flex 
{
	import org.aquiferserver.client.flex.logging.Log;
	import org.aquiferserver.client.flex.logging.LogFactory;
	import org.aquiferserver.common.HandshakeConfirmationMessage;
	import org.aquiferserver.common.AquiferMessage;
	import org.aquiferserver.client.flex.AquiferClientEvent;
	import flash.events.Event;
	/**
	 * ...
	 * @author Seth Albanese
	 * @version $Id: HandshakeConfirmationMessageHandler.as 60 2009-06-15 08:47:09Z salbanese0080@gmail.com $
	 */
	public class HandshakeConfirmationMessageHandler implements MessageHandler
	{
		private var logger:Log = LogFactory.getLog( "org.aquiferserver.client.flex.HandshakeConfirmationMessageHandler" );
		
		public function handleMessage( msg:AquiferMessage, state:GameState ) : void
		{
			logger.debug( "Recieved handshake confirmation message" );
			var hcm:HandshakeConfirmationMessage = HandshakeConfirmationMessage( msg );
			state.localPlayer = hcm.player;
		}
	
		public function get hasResponse() : Boolean { return false; }
		public function get response() : AquiferMessage { return null; }
		public function get generatesEvent() : Boolean { return true; }
		public function get event() : Event { return new AquiferClientEvent( AquiferClientEvent.ON_CONNECT, { connected:true } ); }
	}
	
}